home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 7: Sunsite / Linux Cubed Series 7 - Sunsite Vol 1.iso / system / network / file-tra / fsp-2.7 / fsp-2 / fsp / include / common_def.h < prev    next >
Encoding:
C/C++ Source or Header  |  1993-05-21  |  7.0 KB  |  180 lines

  1.     /*********************************************************************\
  2.     *  Copyright (c) 1991 by Wen-King Su (wen-king@vlsi.cs.caltech.edu)   *
  3.     *                                                                     *
  4.     *  You may copy or modify this file in any manner you wish, provided  *
  5.     *  that this notice is always included, and that you hold the author  *
  6.     *  harmless for any loss or damage resulting from the installation or *
  7.     *  use of this software.                                              *
  8.     \*********************************************************************/
  9.  
  10. #ifndef _FSP_COMMON_DEF_H_
  11. #define _FSP_COMMON_DEF_H_
  12.  
  13. #include <stdio.h>
  14.  
  15. #ifdef VMS
  16. #include "param.h"
  17. #include "types.h"
  18. #include "socket.h"
  19. #include "stat.h"
  20. #include <unixio.h>
  21. #include <unixlib.h>
  22. #define malloc VAXC$MALLOC_OPT
  23. #define realloc VAXC$REALLOC_OPT
  24. #define free VAXC$FREE_OPT
  25. #define unlink delete
  26. #else
  27. #include <sys/param.h>
  28. #include <sys/types.h>
  29. #include <sys/socket.h>
  30. #include <sys/stat.h>
  31. #endif
  32.  
  33. #include <errno.h>
  34. #include <netinet/in.h>
  35.  
  36. #ifdef VMS
  37. #include "time.h"
  38. #else
  39. #include <sys/time.h>
  40. #include <fcntl.h>
  41. #endif
  42.  
  43. #include <signal.h>
  44.  
  45. #ifdef VMS
  46. #include "dirent.h"
  47. #else
  48. #ifdef DIRENT
  49. #include <dirent.h>
  50. #else
  51. #ifdef SYSDIR
  52. #include <sys/dir.h>
  53. #else
  54. #ifdef SYSNDIR
  55. #include <sys/ndir.h>
  56. #endif
  57. #endif
  58. #endif
  59. #endif
  60.  
  61. /****************************************************************************
  62. *  UBUF is the structure of message exchanged between server and clients. 
  63. *
  64. *    The 'buf' part of the buffer is variable lenght up to max of 1024.
  65. *    The 'key' field is used by the server for sequence identification.
  66. *    The 'seq' field is used by the client for sequence identification.
  67. *
  68. *  Client's message to server contain a key value that is the same as the
  69. *  key value of the previous message received from the server.  Similarly,
  70. *  the server's message to client contains a seq value that is the same
  71. *  as the seq value of the previous message from the client. 
  72. *
  73. *  The buf field is logically partitioned into two parts by the len field.
  74. *  The len field indicate the size of the first part of the buffer starting
  75. *  at buf[0].  The rest of the buffer is the second field.  In some cases
  76. *  both fields can contain information.
  77. *
  78. ****************************************************************************/
  79.  
  80. #define UBUF_HSIZE 12                           /* 12 bytes for the header */
  81. #define UBUF_SPACE 1024                    /* maximum payload.        */
  82.  
  83. typedef struct UBUF {            char       cmd; /* message code.             */
  84.                         unsigned char       sum; /* message checksum.         */
  85.                         unsigned char bb_key[2]; /* message key.              */
  86.                         unsigned char bb_seq[2]; /* message sequence number.  */
  87.                         unsigned char bb_len[2]; /* number of bytes in buf 1. */
  88.                         unsigned char bb_pos[4]; /* location in the file.     */
  89.  
  90.                         char   buf[UBUF_SPACE];
  91.                     } UBUF;
  92.  
  93. /* definition of cmd */
  94.  
  95. #define CC_VERSION    0x10    /* return server's version string.    */
  96. #define CC_ERR          0x40    /* error response from server.          */
  97. #define CC_GET_DIR      0x41    /* get a directory listing.             */
  98. #define CC_GET_FILE     0x42    /* get a file.                          */
  99. #define CC_UP_LOAD      0x43    /* open a file for writing.             */
  100. #define CC_INSTALL      0x44    /* close a file opened for writing.     */
  101. #define CC_DEL_FILE     0x45    /* delete a file.                       */
  102. #define CC_DEL_DIR      0x46    /* delete a directory.                  */
  103. #define CC_GET_PRO      0x47    /* get directory protection.            */
  104. #define CC_SET_PRO      0x48    /* set directory protection.            */
  105. #define CC_MAKE_DIR     0x49    /* create a directory.                  */
  106. #define CC_BYE          0x4A    /* finish a session.                    */
  107. #define CC_GRAB_FILE    0x4B    /* atomic get+delete a file.        */
  108. #define CC_GRAB_DONE    0x4C    /* atomic get+delete a file done.    */
  109. #define CC_LIMIT    0x80    /* # > 0x7f for future cntrl blk ext.   */
  110.  
  111. /* definition of global bitfield for version information */
  112. /* Global information is also going to be a bit vector   */
  113. #define VER_BYTES    1    /* currently only 8 bits or less of info  */
  114. #define VER_LOG        0x01    /* does the server do logging             */
  115. #define VER_READONLY    0x02    /* is the server in readonly mode         */
  116. #define VER_REVNAME    0x04    /* does the server refuse non reversables */
  117. #define VER_PRIVMODE    0x08    /* Is the server being run 'private' mode */
  118. #define VER_THRUPUT    0x10    /* does the server enforce thruput control*/
  119.  
  120. /* definition of directory bitfield for directory information */
  121. /* directory information is just going to be a bitfield encoding
  122.  * of which protection bits are set/unset
  123.  */
  124. #define PRO_BYTES    1    /* currently only 8 bits or less of info  */
  125. #define DIR_OWNER    0x01    /* does caller own directory              */
  126. #define DIR_DEL        0x02    /* can files be deleted from this dir     */
  127. #define DIR_ADD        0x04    /* can files be added to this dir         */
  128. #define DIR_MKDIR    0x08    /* can new subdirectories be created      */
  129. #define DIR_PRIV    0x10    /* are files readable by non-owners       */
  130. #define DIR_README    0x20    /* does this dir contain an readme file?  */
  131.  
  132. /* definition of logging information */
  133. #define L_NONE        0x000
  134. #define L_ERR        0x001
  135. #define L_VER        0x002
  136. #define L_GETDIR    0x004
  137. #define L_GETFILE    0x008
  138. #define L_UPLOAD    0x010
  139. #define L_INSTALL    0x020
  140. #define L_DELFILE    0x040
  141. #define L_DELDIR    0x080
  142. #define L_SETPRO    0x100
  143. #define L_MAKEDIR    0x200
  144. #define L_GRABFILE    0x400
  145. #define L_GETPRO    0x800
  146. #define L_ALL        0xfff
  147.  
  148. /****************************************************************************
  149. *  RDIRENT is the structure of a directory entry contained in a .FSP_CONTENT
  150. *  file.  Each entry contains a 4 bytes quantity 'time', a 4 bytes quentity
  151. *  'size', and 1 byte of 'type'.  Then followed by x number of bytes of
  152. *  'name'.  'name' is null terminated.  Then followed by enough number of
  153. *  padding to fill to an 4-byte boundary.  At this point, if the next entry
  154. *  to follow will spread across 1k boundary, then two possible things will
  155. *  happen.  1) if the header fits between this entry and the 1k boundary,
  156. *  a complete header will be filled in with a 'type' set to RDTYPE_SKIP.
  157. *  And then enough bytes to padd to 1k boundary.  2) if the header does
  158. *  not fit, then simply pad to the 1k boundary.  This will make sure that
  159. *  messages carrying directory information carry only complete directory
  160. *  entries and no fragmented entries.  The last entry is type RDTYPE_END.
  161. ****************************************************************************/
  162.  
  163. #define RDHSIZE (2*4+1)
  164.  
  165. typedef struct RDIRENT { unsigned char bb_time[4];
  166.                          unsigned char bb_size[4];
  167.                          unsigned char type      ;
  168.                          char          name[1]   ; } RDIRENT;
  169.  
  170. #define RDTYPE_END      0x00
  171. #define RDTYPE_FILE     0x01
  172. #define RDTYPE_DIR      0x02
  173. #define RDTYPE_SKIP     0x2A
  174.  
  175. #define NULLP ((char *) 0)
  176.  
  177. #define MIN_DELAY    500L
  178.  
  179. #endif /* _FSP_COMMON_DEF_H_ */
  180.